package com.example.q_kang.hhh.setting;

import com.hjq.toast.ToastUtils;
import com.lzy.okgo.model.Response;
import com.sskj.base.BasePresenter;
import com.sskj.base.api.Constant;
import com.sskj.base.base.HttpData;
import com.example.q_kang.hhh.api.JsonCallBack;


/**
 * @author Hey
 * Create at  2019/04/10
 */
class SetDealPwdPresenter extends BasePresenter<SetDealPwdActivity> {

    public void sendCode(String mobile) {
        httpService.getCode(mobile)
                .tag(this)
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtils.show(httpData.getMsg());
                        if (httpData.getStatus() == Constant.OK) {
                            mView.sendCodeSuccess();
                        }

                    }
                });
    }


    public void changePayPwd(String pwd, String code) {
        httpService.changePayPwd(pwd, code)
                .tag(this)
                .execute(new JsonCallBack<HttpData>() {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtils.show(httpData.getMsg());
                        if (httpData.getStatus() == Constant.OK) {
                            mView.finish();
                        }
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.hideLoading();
                    }
                });


    }
}
